import datetime
from typing import Type

from sqlalchemy import or_, func, Integer, select, text, outerjoin
from sqlalchemy.orm import Session

from module_admin.entity.do.cms_driver import CmsDriver
from module_admin.entity.do.cms_order import CmsOrder
from module_admin.entity.do.cms_order_dispatch import CmsOrderDispatch
from module_admin.entity.do.cms_order_execute import CmsOrderExecute
from module_admin.entity.do.resource import Resource
from module_admin.entity.vo.cms_driver_vo import DriverModel, DriverForQuery, DriverModelFree
from module_admin.entity.vo.cms_home_vo import MyTime
from module_admin.enum.state_enum import OrderStateEnum
from utils.stringUtils import stringUtils
from utils.time_format_util import object_format_datetime, list_format_datetime


class ResourceDao:

    @classmethod
    def delete_driver_by_owner_and_name(cls, db: Session, owner: str, name: str):
        db.query(Resource) \
            .filter(Resource.owner == owner) \
            .filter(Resource.name == name) \
            .delete()
        db.commit()
